package com.wfs.suanfa.jvm;

/**
 * @author wfs
 * @date 2021/1/5 21:12
 */
public class DCLTest {
    private static volatile DCLTest dclTest;
    private DCLTest(){

    }
    public static DCLTest getInstance(){
        //锁细化
        if (dclTest==null){
            synchronized (DCLTest.class){
                if (dclTest==null){
                    try {
                        Thread.sleep(1);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    dclTest=new DCLTest();
                    // 初始化对象三步: 1.分配内存  2.初始化  3.内存地址指向给对象
                }
            }
        }
        return dclTest;
    }
    public static void main(String[] args) {

    }
}
